package cn.dubito.springboot.learning.converter;

import cn.dubito.springboot.learning.dataobject.OrderMaster;
import cn.dubito.springboot.learning.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liliang
 * @description:
 * @date 2018/1/13.
 */
public class OrderMasterToOrderDtoConverter {

    public static OrderDTO convert(OrderMaster orderMaster) {
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster, orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList) {
       return orderMasterList.stream().map(e -> convert(e)).collect(Collectors.toList());
    }
}
